package cn.sirun.com.fca.map.uitl;

import android.text.TextUtils;

import com.google.gson.reflect.TypeToken;
import com.tencent.cloud.iov.util.storage.TXSharedPreferencesUtils;

import java.util.List;

import cn.sirun.com.fca.map.model.bean.AddressBean;

/**
 * @author vinsonhuang
 * @date 2018/10/10
 */
public class AddressHistoryUtils {

    public static void saveAddressHistory(List<AddressBean> addressBean) {
        if (null != addressBean) {
            TXSharedPreferencesUtils.setValue("addressHistory",
                    GsonHelper.getGson().toJson(addressBean));
        } else {
            TXSharedPreferencesUtils.remove("addressHistory");
        }
    }

    public static List<AddressBean> getAddressHistoty() {
        String personalInfoString = TXSharedPreferencesUtils.getValue(
                "addressHistory");
        if (TextUtils.isEmpty(personalInfoString)) {
            return null;
        }
        return GsonHelper.getGson().fromJson(personalInfoString, new TypeToken<List<AddressBean>>(){}.getType());
    }

}
